package top.infopub.mgr.mkt.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.infopub.enums.mkt.StandardEnum;
import top.infopub.generic.GenericDao;
import top.infopub.generic.GenericServiceImpl;
import top.infopub.mgr.common.vo.ErrorCodeEnum;
import top.infopub.mgr.common.vo.RspVo;
import top.infopub.mgr.mkt.dao.BaseLineDao;
import top.infopub.mgr.mkt.dao.ProjectSubInfoDao;
import top.infopub.mgr.mkt.dao.StandardSubDao;
import top.infopub.mgr.mkt.service.BaseLineService;
import top.infopub.mgr.mkt.service.ProjectInfoService;
import top.infopub.mgr.mkt.service.StandardSubService;
import top.infopub.mgr.mkt.vo.BaseLineVo;
import top.infopub.mgr.mkt.vo.InvestmentInfoVo;
import top.infopub.mgr.sg.service.CitySurveyService;
import top.infopub.mgr.util.DateUtils;
import top.infopub.mgr.util.LogUtil;
import top.infopub.model.mkt.BaseLine;
import top.infopub.model.mkt.ProjectInfo;
import top.infopub.model.mkt.ProjectSubInfo;
import top.infopub.model.mkt.StandardSub;
import top.infopub.model.sg.CitySurvey;
import top.infopub.security.util.SessionUserUtils;
import top.infopub.security.vo.AuthorizationVO;
import top.infopub.util.IdFactory;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;



@Service
public class BaseLineServiceImpl extends GenericServiceImpl<BaseLine, String> implements BaseLineService {

	@Autowired
	private BaseLineDao baseLineDao;

	@Autowired
	private StandardSubDao standardSubDao;

	@Autowired
	private ProjectInfoService projectInfoService;

	@Autowired
	private CitySurveyService citySurveyService;
	@Autowired
	private ProjectSubInfoDao projectSubInfoDao;
	@Autowired
	private StandardSubService standardSubService;

	@Override
	public GenericDao<BaseLine, String> getDao() {
		return baseLineDao;
	}

	@Override
	public void addBaseLine(BaseLine baseLine) {
		baseLineDao.insertSelective(baseLine);
	}

	@Override
	public void editBaseLine(BaseLine baseLine) {
		baseLineDao.updateByIdSelective(baseLine);
	}

	@Override
	public void updateByFlagKey(String flag, String id) {
		baseLineDao.updateByFlagKey(flag, id);
	}

	@Override
	public int checkSgCityName(String sgCityName, String id) {
		return baseLineDao.checkSgCityName(sgCityName, id);
	}

	/**
	 * 判断项目是否满足底线标准
	 * @param proCode
	 * @return
	 */
	@Override
	public List<BaseLineVo> checkIsSatisfy(String proCode) {
		//项目基本信息
		ProjectInfo projectInfo = projectInfoService.findByProCode(proCode);
		BaseLineVo baseLineVo = new BaseLineVo();
		if (StringUtils.isNotEmpty(projectInfo.getRefProvinceId())){
			baseLineVo.setQueryProvinceId(projectInfo.getRefProvinceId());
		}
		if (StringUtils.isNotEmpty(projectInfo.getRefCityId())){
			baseLineVo.setQueryCityId(projectInfo.getRefCityId());
		}
		if (StringUtils.isNotEmpty(projectInfo.getRefAreaId())){
			baseLineVo.setQueryAreaId(projectInfo.getRefAreaId());
		}
		//根据项目地址查询对应底线标准信息ID
		String baseLineId = baseLineDao.selectByAddress(baseLineVo);
		if (StringUtils.isBlank(baseLineId) && projectInfo.getRefProvinceId()!=null){
			BaseLineVo baseLineVo1 = new BaseLineVo();
			baseLineVo1.setQueryProvinceId(projectInfo.getRefProvinceId());
			baseLineId = baseLineDao.selectByAddress(baseLineVo1);
		}

		if (StringUtils.isBlank(baseLineId)){
			BaseLineVo baseLineVo2 = new BaseLineVo();
			baseLineVo2.setQueryProvinceId("0");
			baseLineId = baseLineDao.selectByAddress(baseLineVo2);
		}
		//根据底线标准ID查询底线标准明细
		List<StandardSub> standardSubs = standardSubDao.selectByLineId(baseLineId);
		//查询一般公共预算收入
		CitySurvey citySurvey = citySurveyService.selectByCityId(projectInfo.getSgCityId());
		List<BaseLineVo> vos = new ArrayList<>();
		if (standardSubs.size()>0){
			for (StandardSub standardSub : standardSubs) {
					BaseLineVo vo = new BaseLineVo();
					BigDecimal bd = null;
					if (!StandardEnum.RUKU_QINGKUANG.getCode().equals(standardSub.getStandardCode())) {
						bd = new BigDecimal(standardSub.getStandardValue());
					}
					switch (standardSub.getStandardCode()) {
						case "1":
							//一般公共预算收
							vo.setStandardName(standardSub.getStandardName());//当前标准名称
							vo.setStandardCode(standardSub.getStandardValue()); //当前标准值
							vo.setNowProgress(citySurvey.getPubIncome().toString()); //当前进度
							int com = citySurvey.getPubIncome().compareTo(bd);
							if (">".equals(standardSub.getStandardRule())) {
								if (com == 1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("<".equals(standardSub.getStandardRule())) {
								if (com == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (com == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (com == 1 || com == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (com == -1 || com == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
//							 建安占比
						case "2":
							//建安占比等于建安工程费用总和/总投资额
							//根据proCode查询建安占比总和
							ProjectSubInfo projectSubInfo = projectSubInfoDao.queryByProCode(proCode);
							List<InvestmentInfoVo> investmentInfoVos = JSON.parseArray(projectSubInfo.getContentJson(), InvestmentInfoVo.class);
							BigDecimal rowSum = BigDecimal.ZERO;
							for (InvestmentInfoVo investmentInfoVo : investmentInfoVos) {
								if (StandardEnum.GET_JIANAN.getBaseLineName().equals(investmentInfoVo.getName())
								){
									 rowSum = investmentInfoVo.getTotal();
								}
							}
							BigDecimal divide = rowSum.divide(projectInfo.getSumAmount(),2, BigDecimal.ROUND_HALF_UP);
							BigDecimal best  = new BigDecimal(100);
							BigDecimal multiply = divide.multiply(best);
							int divide1 = multiply.compareTo(bd);
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							//转化百分比
							vo.setNowProgress(multiply.toString());
								if (">".equals(standardSub.getStandardRule())) {
									if (divide1 == 1) {
										vo.setResult(true);
										vo.setResultMsg("满足标准");
									}
								} else if ("<".equals(standardSub.getStandardRule())) {
								if (divide1 == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (divide1 == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (divide1 == 1 || divide1 == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (divide1 == -1 || divide1 == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
						//总投资额
						case "3":
							int sum = projectInfo.getSumAmount().compareTo(bd);
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							vo.setNowProgress(projectInfo.getSumAmount().toString());
							if (">".equals(standardSub.getStandardRule())) {
								if (sum == 1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("<".equals(standardSub.getStandardRule())) {
								if (sum == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (sum == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (sum == 1 || sum == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (sum == -1 || sum == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
							// 入库情况
						case "4":
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							vo.setNowProgress(projectInfo.getIsInStore());
							if (projectInfo.getIsInStore().equals(standardSub.getStandardValue())) {
								vo.setResult(true);
								vo.setResultMsg("满足标准");
							}
							break;
							//建安工程费
						case "5":
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							vo.setNowProgress(projectInfo.getSumCae().toString());
							int cae = projectInfo.getSumCae().compareTo(bd);
							if (">".equals(standardSub.getStandardRule())) {
								if (cae == 1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("<".equals(standardSub.getStandardRule())) {
								if (cae == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (cae == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (cae == 1 || cae == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (cae == -1 || cae == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
							//运营周期
						case "6":
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							vo.setNowProgress(projectInfo.getOmYears().toString());
							int om = projectInfo.getOmYears().compareTo(bd);
							if (">".equals(standardSub.getStandardRule())) {
								if (om == 1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("<".equals(standardSub.getStandardRule())) {
								if (om == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (om == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (om == 1 || om == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (om == -1 || om == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
							//建设周期
						case "7":
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							vo.setNowProgress(projectInfo.getBuildYears().toString());
							int bil = projectInfo.getBuildYears().compareTo(bd);
							if (">".equals(standardSub.getStandardRule())) {
								if (bil == 1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("<".equals(standardSub.getStandardRule())) {
								if (bil == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (bil == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (bil == 1 || bil == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (bil == -1 || bil == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
							//合作周期
						case "8":
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							vo.setNowProgress(projectInfo.getWorkYears().toString());
							int work = projectInfo.getWorkYears().compareTo(bd);
							if (">".equals(standardSub.getStandardRule())) {
								if (work == 1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("<".equals(standardSub.getStandardRule())) {
								if (work == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (work == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (work == 1 || work == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (work == -1 || work == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
							//资本金比例
						case "9":
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							vo.setNowProgress(projectInfo.getCapitalPercent().toString());
							int cap = projectInfo.getCapitalPercent().compareTo(bd);
							if (">".equals(standardSub.getStandardRule())) {
								if (cap == 1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("<".equals(standardSub.getStandardRule())) {
								if (cap == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (cap == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (cap == 1 || cap == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (cap == -1 || cap == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
							//投资回报率
						case "10":
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							vo.setNowProgress(projectInfo.getInvestBackRate().toString());
							int rate = projectInfo.getInvestBackRate().compareTo(bd);
							if (">".equals(standardSub.getStandardRule())) {
								if (rate == 1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("<".equals(standardSub.getStandardRule())) {
								if (rate == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (rate == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (rate == 1 || rate == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (rate == -1 || rate == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
						//融资回报率
						case "11":
							vo.setStandardName(standardSub.getStandardName());
							vo.setStandardCode(standardSub.getStandardValue());
							vo.setNowProgress(projectInfo.getFinBackRate().toString());
							int back = projectInfo.getFinBackRate().compareTo(bd);
							if (">".equals(standardSub.getStandardRule())) {
								if (back == 1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("<".equals(standardSub.getStandardRule())) {
								if (back == -1) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("=".equals(standardSub.getStandardRule())) {
								if (back == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≥".equals(standardSub.getStandardRule())) {
								if (back == 1 || back == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							} else if ("≤".equals(standardSub.getStandardRule())) {
								if (back == -1 || back == 0) {
									vo.setResult(true);
									vo.setResultMsg("满足标准");
								}
							}
							break;
					}
				vos.add(vo);
			}
		}

		return vos;
}

	@Override
	public List<StandardSub> getStandard(String address) {
		String[] split = address.split(",");
		//根据省市区查询底线标准情况
		BaseLineVo baseLineVo = new BaseLineVo();
		if (split.length>0){
			baseLineVo.setQueryProvinceId(split[0]); //省
		}
		if (split.length>1){
			baseLineVo.setQueryCityId(split[1]); //市
		}
		if (split.length>2){
			baseLineVo.setQueryAreaId(split[2]);//区
		}
		String baseLineId = baseLineDao.selectByAddress(baseLineVo);//标准id
        //根据id查询对应的标准详情
		List<StandardSub> standardSubs = standardSubDao.selectByLineId(baseLineId);

		if (standardSubs.size()>0){
			return standardSubs;
		}else {
			baseLineVo.setQueryProvinceId("0");
			String baseLineId2 = baseLineDao.selectByAddress(baseLineVo);//标准id
			List<StandardSub> standardSubs2 = standardSubDao.selectByLineId(baseLineId2);
			return standardSubs2;
		}
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public RspVo edit(HttpServletRequest request, BaseLine baseLine) {
		AuthorizationVO vo = SessionUserUtils.getSessionAttributeForUserDtl();
		baseLine.setUptBy(vo.getId());
		baseLine.setUptTime(DateUtils.getCurrentDateTime());
		baseLineDao.updateByIdSelective(baseLine);

		String[] standardName = request.getParameterValues("standardName");// // 标准名称CODE
		String[] standardRule = request.getParameterValues("standardRule");// 标准规则
		String[] standardValue = request.getParameterValues("standardValue");// 标准值
		if (standardName != null && standardName.length > 0) {

			standardSubService.deleteByBaseLineId(baseLine.getId());
			StandardSub standardSub;
			List<StandardSub> standardSubs = new ArrayList<StandardSub>();
			int ruleIndex = 0;
			for (int i = 0; i < standardName.length; i++) {
				standardSub = new StandardSub();
				standardSub.setId(IdFactory.getUUIDUpper());
				standardSub.setBaseLineId(baseLine.getId());
				standardSub.setStandardCode(standardName[i]);
				standardSub.setStandardName(StandardEnum.getValue(standardName[i]));
				if (standardName[i].equals("4")) {
					standardSub.setStandardRule(" ");
				} else {
					standardSub.setStandardRule(standardRule[ruleIndex]);
					ruleIndex++;
				}
				standardSub.setStandardValue(standardValue[i]);
				standardSub.setAddBy(vo.getId());
				standardSub.setAddTime(DateUtils.getCurrentDateTime());
				standardSubs.add(standardSub);
			}
			if (standardSubs.size() > 0) {
				standardSubService.insertByBatch(standardSubs);
			}
		} else {
			return ErrorCodeEnum.ERROR_COMMON_CHECK.getRspVo("标准名称未选择");
		}

		LogUtil.bizLog(LogUtil.LogModelType.PROJECT, LogUtil.AcctionType.ADD, "底线标准 -新增地区底线标准：名称=" + baseLine.getSgCityName(), null);
		return RspVo.getSuccessResponse();
	}

	@Override
	public Page<BaseLineVo> selectPageByDomainWhere(Page<BaseLineVo> page, BaseLineVo baseLineVo) {
		PageHelper.startPage(page.getPageNum(), page.getPageSize());
		List<BaseLineVo> baseLineVos = baseLineDao.selectByDomainWhere(baseLineVo);
		List<StandardSub> standardSubs;
		JSONObject subJson;
		for (BaseLineVo baseLine : baseLineVos) {
			standardSubs = standardSubDao.selectByLineId(baseLine.getId());
			baseLine.setStandardSubs(standardSubs);
			if (standardSubs.size() > 0) {
				subJson = new JSONObject();
				for (StandardSub standardSub : standardSubs) {
					if (!subJson.containsKey(standardSub.getStandardName())) {
						subJson.put(standardSub.getStandardName(),
								standardSub.getStandardRule() + standardSub.getStandardValue());
					}
				}
				baseLine.setStandardSubJson(subJson);
			}
		}
		return (Page<BaseLineVo>) baseLineVos;
	}

	@Override
	public List<BaseLineVo> selectBySgCityId(String sgCityId, Integer type, Object o) {
//		BigDecimal sumCae = new BigDecimal(0);
//		BigDecimal pubIncome = new BigDecimal(0);
//		BigDecimal sumAmount = new BigDecimal(0);
//		BigDecimal omYears = new BigDecimal(0);
//		BigDecimal buildYears = new BigDecimal(0);
//		String isInStore = "";
//		if (type == 1) {
//			CollectProjectVo vo = new CollectProjectVo();
//			vo = (CollectProjectVo) o;
//			pubIncome = vo.getPubIncome();
//			sumAmount = vo.getSumAmount();
//			omYears = vo.getOmYears();
//			buildYears = vo.getBuildYears();
//			isInStore = vo.getIsInStore();
//			sumCae = vo.getSumCae();
//		}
//		if (type == 2) {
//			PreProjectVo vo = new PreProjectVo();
//			vo = (PreProjectVo) o;
//			pubIncome = vo.getPubIncome();
//			sumAmount = vo.getSumAmount();
//			omYears = vo.getOmYears();
//			buildYears = vo.getBuildYears();
//			isInStore = vo.getIsInStore();
//			sumCae = vo.getSumCae();
//		}
//		if (pubIncome == null)
//			pubIncome = new BigDecimal(0);
//		if (sumAmount == null)
//			sumAmount = new BigDecimal(0);
//		if (omYears == null)
//			omYears = new BigDecimal(0);
//		if (buildYears == null)
//			buildYears = new BigDecimal(0);
//
//		List<BaseLine> baseLines = baseLineDao.selectBySgCityId(sgCityId);
//		if (baseLines == null || baseLines.size() == 0) {
//			baseLines = baseLineDao.selectBySgCityIdNull(sgCityId);
//		}
		List<BaseLineVo> vos = new ArrayList<>();
//		for (BaseLine baseLine : baseLines) {
//			BaseLineVo vo = new BaseLineVo();
//			BeanUtils.copyProperties(baseLine, vo);
//			BigDecimal bd = null;


			//不需要
//			if (!"4".equals(baseLine.getStandardId())) {
//				bd = new BigDecimal(baseLine.getStandardValue());
//			}
//
//			switch (baseLine.getStandardId()) {
//			case "1":
//				vo.setStandardName(pubIncome + "");
//				int com = pubIncome.compareTo(bd);
//				if (">".equals(baseLine.getStandardRule())) {
//					if (com == 1) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("<".equals(baseLine.getStandardRule())) {
//					if (com == -1) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("=".equals(baseLine.getStandardRule())) {
//					if (com == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≥".equals(baseLine.getStandardRule())) {
//					if (com == 1 || com == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≤".equals(baseLine.getStandardRule())) {
//					if (com == -1 || com == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				}
//				break;
//			case "2":
//				String standardValue = baseLine.getStandardValue();
//				BigDecimal zero = new BigDecimal(0);
//				BigDecimal divide = sumCae.divide(sumAmount, 2, BigDecimal.ROUND_HALF_UP);
//				String v = Float.parseFloat(standardValue) / 100 + "";
//				BigDecimal value = new BigDecimal(v);
//				int div = divide.compareTo(value);
//				vo.setStandardName(divide.multiply(new BigDecimal(100)).toString());
//				if (zero.compareTo(sumAmount) != 0) {
//					if (">".equals(baseLine.getStandardRule())) {
//						if (div == 1) {
//							vo.setResult(true);
//							vo.setResultMsg("满足标准");
//						}
//					}
//				} else if ("<".equals(baseLine.getStandardRule())) {
//					if (div == -1) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("=".equals(baseLine.getStandardRule())) {
//					if (div == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≥".equals(baseLine.getStandardRule())) {
//					if (div == 1 || div == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≤".equals(baseLine.getStandardRule())) {
//					if (div == -1 || div == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				}
//				break;
//			case "3":
//				vo.setStandardName(sumAmount + "");
//				int sum = sumAmount.compareTo(bd);
//				if (">".equals(baseLine.getStandardRule())) {
//					if (sum == 1) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("<".equals(baseLine.getStandardRule())) {
//					if (sum == -1) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("=".equals(baseLine.getStandardRule())) {
//					if (sum == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≥".equals(baseLine.getStandardRule())) {
//					if (sum == 1 || sum == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≤".equals(baseLine.getStandardRule())) {
//					if (sum == -1 || sum == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				}
//				break;
//			case "4":
//				String standard = baseLine.getStandardValue();
//				String in = "";
//				if ("0".equals(isInStore)) {
//					in = "未入库";
//					vo.setStandardName("未入库");
//				}
//				if ("1".equals(isInStore)) {
//					in = "已入库";
//					vo.setStandardName("已入库");
//				}
//
//				if (in.equals(standard)) {
//					vo.setResult(true);
//					vo.setResultMsg("满足标准");
//				}
//				break;
//			case "6":
//				vo.setStandardName(omYears + "");
//				int om = omYears.compareTo(bd);
//				if (">".equals(baseLine.getStandardRule())) {
//					if (om == 1) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("<".equals(baseLine.getStandardRule())) {
//					if (om == -1) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("=".equals(baseLine.getStandardRule())) {
//					if (om == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≥".equals(baseLine.getStandardRule())) {
//					if (om == 1 || om == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≤".equals(baseLine.getStandardRule())) {
//					if (om == -1 || om == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				}
//				break;
//			case "7":
//				vo.setStandardName(buildYears + "");
//				int bil = buildYears.compareTo(bd);
//				if (">".equals(baseLine.getStandardRule())) {
//					if (bil == 1) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("<".equals(baseLine.getStandardRule())) {
//					if (bil == -1) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("=".equals(baseLine.getStandardRule())) {
//					if (bil == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≥".equals(baseLine.getStandardRule())) {
//					if (bil == 1 || bil == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				} else if ("≤".equals(baseLine.getStandardRule())) {
//					if (bil == -1 || bil == 0) {
//						vo.setResult(true);
//						vo.setResultMsg("满足标准");
//					}
//				}
//				break;
//			}
		//以上不需要

//			vos.add(vo);
//		}

		return vos;
	}

}
